/**
 * 
 */
package co.fitstart.coach.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.demo2do.core.persistence.GenericDaoSupport;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.course.schedule.CourseSchedule;
import co.fitstart.entity.course.schedule.ScheduleStatus;
import co.fitstart.entity.user.Student;

/**
 * @author downpour
 *
 */
@Repository("courseDaoSupport")
public class CourseDaoSupport {
    
    @Autowired
    private GenericDaoSupport genericDaoSupport;
    
    
    /**
     * 
     * @param courseRound 
     * @param student
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<CourseSchedule> getCourseSchedule(CourseRound courseRound, Student student) {
        
        String sentence = "FROM CourseSchedule courseSchedule WHERE courseSchedule.disabled = false AND courseSchedule.student = :student AND courseSchedule.courseRound = :courseRound AND courseSchedule.courseStatus = :status";
        
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("courseRound", courseRound);
        parameters.put("student", student);
        parameters.put("status", ScheduleStatus.SCHEDULE);
        
        return genericDaoSupport.searchForList(sentence, parameters);
    }
    
}
